package com.example.demo.repository;

import java.util.Map;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;

import com.example.demo.framework.base.BaseRepository;
import com.example.demo.model.AfterSale;

public interface AfterSaleRepository extends BaseRepository<AfterSale, Long>{

	
	@Query("from AfterSale a where a.aID = ?1")
	public AfterSale getByID(Long aID);
	
	@Query("from AfterSale a where a.tradeID = ?1")
	public AfterSale getBytradeID(String tradeID);
	
	@Query(value="SELECT new Map(a.recordStr as recordStr,a.tradeID as tradeID,a.status as status) FROM "
			+ "AfterSale a LEFT JOIN Trade t ON a.tradeID=t.tradeID LEFT JOIN Order o on t.tradeID=o.tradeID WHERE t.userID= ?1 ")
	public Page<Map<String, Object>> pageAfterSaleByUserId(Long userID,Pageable pageable);
}
